package com.example.javabase.multithread.threadlocal;

/**
 * @author He Changjie on 2021/7/11
 */
public class MainTest1 {
    public static void main(String[] args) {
        ThreadLocal<String> t = new ThreadLocal<>();
        Thread thread0 = new Thread(() -> {
            t.set("thread0");
            System.out.println(t.get());
            t.remove();
            System.out.println(t.get());
        });
        Thread thread1 = new Thread(() -> {
            t.set("thread1");
            System.out.println(t.get());
            t.remove();
            System.out.println(t.get());
        });
        Thread thread2 = new Thread(() -> {
            System.out.println(t.get());
        });
        thread0.start();
        thread1.start();
        thread2.start();
    }
}
